package servlet.image;

import bean.Result;
import com.google.gson.Gson;
import dao.ProductImage;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "RemoveImageServlet", value = "/RemoveImageServlet.s")
public class RemoveImageServlet extends HttpServlet {
    private ProductImage dao =new ProductImage();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        final String imageid = request.getParameter("imageid");
        final int status = dao.deleteImage(imageid);
        Result result;
        if (status==1){
            result = new Result(1,"删除成功",0);
        }else {
            result = new Result(1,"删除失败",0);

        }
        final String json = new Gson().toJson(result);
        response.getWriter().append(json);

    }
}
